﻿import requests, re, multiprocessing


def main(url):
    response = requests.get(url)
    html = response.text
    imgs_name = re.findall('alt="(.*?)"', html, re.S)
    imgs_url = re.findall('data-original="(.*?)"', html, re.S)
    for img_name, img_url in zip(imgs_name, imgs_url):
        print('正在抓取: ' + img_url)
        print(img_name)
        response = requests.get(img_url, timeout=10)
        with open(r'E:\demo' + '\\' + img_name + '.jpg', 'wb') as f:
            f.write(response.content)
        print('success')


if __name__ == '__main__':
    url = 'http://www.doutula.com/photo/list/?page='
    pool = multiprocessing.Pool()
    pool.map(main, [url + str(i) for i in range(10, 20)]) # 10页
